import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';

// import { h } from 'vue';
import { DictEnum } from '@vben/constants';
// import { VbenIcon } from '@vben/icons';
import { getPopupContainer } from '@vben/utils';

// import { Tag } from 'ant-design-vue';
// import { z } from '#/adapter/form';
import { getDictOptions } from '#/utils/dict';
import { renderDict } from '#/utils/render';

export const querySchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    fieldName: 'name',
    label: '名称',
  },
  // {
  //   component: 'Select',
  //   fieldName: 'type',
  //   componentProps: {
  //     getPopupContainer,
  //     options: getDictOptions(DictEnum.INVITATIONS_TEMPLATE_TYPE, true),
  //   },
  //   label: '类型',
  // },
  {
    component: 'Select',
    fieldName: 'number',
    label: '届数',
    componentProps: {
      getPopupContainer,
      options: getDictOptions(DictEnum.EXHIBITION_NUMBER, true),
    },
  },
  {
    component: 'DatePicker',
    fieldName: 'createTime',
    label: '创建日期',
    componentProps: {
      format: 'YYYY-MM-DD HH:mm:ss',
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      getPopupContainer,
    },
  },
];

// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
// export const columns: () => VxeGridProps['columns'] = () => [
export const columns: VxeGridProps['columns'] = [
  { type: 'checkbox', width: 60 },
  {
    title: '名称',
    field: 'name',
  },
  // {
  //   title: '类型',
  //   field: 'type',
  //   width: 130,
  //   slots: {
  //     default: ({ row }) => {
  //       return renderDict(row.type, DictEnum.INVITATIONS_TEMPLATE_TYPE, true);
  //     },
  //   },
  // },
  {
    title: '届数',
    field: 'number',
    width: 80,
    slots: {
      default: ({ row }) => {
        return renderDict(row.number, DictEnum.EXHIBITION_NUMBER, true);
      },
    },
  },
  {
    title: '图片文件',
    field: 'imgOssId',
    slots: { default: 'imgOssId' },
  },
  {
    title: '备注',
    field: 'remark',
  },
  {
    title: '创建时间',
    field: 'createTime',
    width: 180,
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
    width: 180,
  },
];

export const drawerSchema: FormSchemaGetter = () => [
  {
    label: '',
    fieldName: 'id',
    component: 'Input',
    dependencies: {
      show: () => false,
      triggerFields: [''],
    },
  },
  {
    label: '名称',
    fieldName: 'name',
    component: 'Input',
    rules: 'required',
  },
  // {
  //   label: '类型',
  //   fieldName: 'type',
  //   component: 'Select',
  //   componentProps: {
  //     getPopupContainer,
  //     options: getDictOptions(DictEnum.INVITATIONS_TEMPLATE_TYPE, true),
  //   },
  //   rules: 'selectRequired',
  // },
  {
    label: '届数',
    fieldName: 'number',
    component: 'Select',
    componentProps: {
      getPopupContainer,
      options: getDictOptions(DictEnum.EXHIBITION_NUMBER, true),
    },
    rules: 'selectRequired',
  },
  {
    label: '图片文件',
    fieldName: 'imgOssId',
    component: 'FileUpload',
    componentProps: {
      accept: '.jpg,.jpeg,.png',
    },
    help: '模板图片尺寸规范：大小800x1600；\n二维码尺寸规范：大小155x155；\n二维码位置规范：距离上方1375px、距离左侧585px',
    rules: 'selectRequired',
  },
  {
    label: '备注',
    fieldName: 'remark',
    component: 'Textarea',
  },
];
